package banco;

import cliente.ClienteBean;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DaoCadastraCliente {

    private Connection conexao;

    public DaoCadastraCliente() throws SQLException {
        this.conexao = DaoConexao.getDaoConexao();
    }

    public void adiciona(ClienteBean cliente) throws SQLException {

        String sql = "INSERT INTO emitente (id,cnpj,ie,rzsocial,fantasia,lgr,nr_lgr,cpto,bairro,cep,"
                + "pais,uf,cidade,fone) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

        PreparedStatement ps = conexao.prepareStatement(sql);

        ps.setString(1, cliente.getId());
        ps.setString(2, cliente.getCnpj());
        ps.setString(3, cliente.getIe());
        ps.setString(4, cliente.getRzsocial());
        ps.setString(5, cliente.getFantasia());
        ps.setString(6, cliente.getLgr());
        ps.setString(7, cliente.getNr_lgr());
        ps.setString(8, cliente.getCpto());
        ps.setString(9, cliente.getBairro());
        ps.setString(10, cliente.getCep());
        ps.setString(11, cliente.getPais());
        ps.setString(12, cliente.getUf());
        ps.setString(13, cliente.getCidade());
        ps.setString(14, cliente.getFone());
        ps.execute();
        ps.close();
    }
}
